09. Demo: Computing Performance
Part 1
Cd13639 C1 L1 DEMO 3 V1
Exploring the Investment Universe
Learn about essential aspects of structuring an investment universe using function libraries, with a focus on understanding historical prices and returns.
Key Components:
- Importing Libraries:
- Essential code components include the function library and Pandas to analyze data effectively.
- Use relative paths to access saved functions correctly.
- Understanding Historical Prices and Returns:
- Generate historical prices and returns using the
create_historical_pricesfunction with one momentum.
- Generate historical prices and returns using the
- Ticker Analysis:
- Identify changes in the number of stock tickers over time, impacting returns.
- Observe the variation from 353 to 498 tickers, suggesting market evolution.
- Survivorship Bias:
- Recognize the effect of excluding removed tickers (usually due to underperformance) on data, resulting in higher average returns.
- Performance Calculation:
- Compute benchmark performance using the
compute BM performancefunction. - Steps include computing daily mean returns, cumulative returns, CAGR, and Sharpe Ratio.
- Use plotting to visualize cumulative and annual returns, providing insights into performance consistency.
- Compute benchmark performance using the
This understanding aids in more informed analyses within a structured investment universe.
Part 2
Cd13639 C1 L1 DEMO 4 V1
Introduction to RSI Indicator Creation
This demonstration focuses on the creation of the RSI (Relative Strength Index) indicator to evaluate trading signals' quality. The key process involves:
Historical Data Preparation:
- Utilize pre-existing historical prices and total returns.
- Isolate one-day returns for a single stock (e.g., Apple) to keep it illustrative.
RSI Calculation Methodology:
- Define gains and losses: Gains are returns > 0, losses < 0.
- Calculate rolling means for gains and losses over a specified window.
- Use forward fill to handle missing values, ensuring seamless data continuity.
- Compute the RSI as gain-to-loss ratio, normalizing between 0-100.
Implementation and Analysis:
- Apply the calculate RSI function across multiple data sets to evaluate all tickers.
- Assess the relationship between RSI and forward returns; note the weak correlation typical in investment data.
Practical Insights:
- Examine RSI value bins for stocks with values below 30 or above 70; these bins can indicate potential underpricing or overpricing.
- Calculate average returns for different bins, focusing on bins with RSI < 30 for possible higher yield.
These steps provide a foundational understanding of implementing RSI in trading algorithms, setting the stage for future explorations and optimizations.